# Contributor: Julian P Samaroo <jpsamaroo@jpsamaroo.me>
# Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=mmsd-tng
pkgver=2.5.0
pkgrel=1
pkgdesc="daemon for receiving and managing GSM MMS messages"
url="https://gitlab.com/kop316/mmsd"
arch="all"
license="GPL-2.0-only"
# upstream was renamed mmsd-->mmsd-tng
provides="mmsd=$pkgver-r$pkgrel"
replaces="mmsd"
depends="mobile-broadband-provider-info"
makedepends="
	c-ares-dev
	dbus-dev
	glib-dev
	json-c-dev
	libphonenumber-dev
	libsoup3-dev
	meson
	modemmanager-dev
	"
source="
	$pkgname-$pkgver.tar.gz::https://gitlab.com/kop316/mmsd/-/archive/$pkgver/mmsd-$pkgver.tar.gz
	mmsd.desktop
	"
subpackages="$pkgname-tools"
builddir="$srcdir/${pkgname%%-tng}-$pkgver"

build() {
	abuild-meson \
		-Db_lto=true \
		-Dbuild-mmsctl=true \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	install -Dm644 "$srcdir"/mmsd.desktop \
		"$pkgdir"/etc/xdg/autostart/mmsd.desktop

	install -Dm755 \
		output/tools/create-hex-array \
		output/tools/decode-mms \
		-t "$pkgdir"/usr/bin/
}

tools() {
	pkgdesc="$pkgdesc (tools)"

	amove usr/bin/create-hex-array
	amove usr/bin/decode-mms
}

sha512sums="
a8d2525de55a84b29aeb7ab2c07991853030eb071eddae142a3b760dfb96845f111d38f6ae2a0f0da12a80ad66eac6c3be8b0397ba27a5f24d5acd0f9b75a752  mmsd-tng-2.5.0.tar.gz
5d558e14baf0324ba1d7ddd7b89a558cc4570dd44cfba964bddcd03d6e68c514aaf8a25be927ff4e095f6e08b592307ebd333f41c8747ce1a13793420a6086d8  mmsd.desktop
"
